local qiwo = fk.CreateSkill{
  name = "wk_heg__qiwo",
}

Fk:loadTranslationTable{
  ["wk_heg__qiwo"] = "启沃",
  [":wk_heg__qiwo"] = "与你势力相同的角色出牌阶段开始时，你可以展示所有手牌并弃置其中一种花色的所有牌，令其于此回合内使用此花色的牌不能被响应。",
  ["@wk_heg__qiwo-turn"] = "启沃",
  ["#wk_heg__qiwo"] = "启沃：选择一种花色",
  ["#wk_heg__qiwo-dis"] = "启沃：你可弃置一种花色的所有牌，令 %dest 于此回合内使用该花色的牌不能被响应",
}

local H = require "packages.ol_hegemony.util"
local HG = require "packages.new_heg_diy_my.util"
local U = require "packages.utility.utility"

qiwo:addEffect(fk.EventPhaseStart, {
  anim_type = "support",
  events = {fk.EventPhaseStart},
  can_trigger = function (self, event, target, player, data)
    return  player:hasSkill(self) and target.phase == Player.Play and H.compareKingdomWith(player, target) and not player:isKongcheng()
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = qiwo.name,
      prompt = "#wk_heg__qiwo-dis::"..target.id
    })
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    player:showCards(player:getCardIds(Player.Hand))
    room:delay(200)
    local all_suit = {"log_spade", "log_heart", "log_club", "log_diamond"}
    local suit = {}
    for _, cid in ipairs(player:getCardIds(Player.Hand)) do
      table.insertIfNeed(suit, U.ConvertSuit(Fk:getCardById(cid).suit, "int", "sym"))
    end
    table.removeOne(suit, "log_nosuit")
    local choice = room:askToChoice(player, {
      all_choices = all_suit,
      choices = suit,
      skill_name = qiwo.name,
      cancelable = false,
      prompt = "#wk_heg__qiwo-dis::"..target.id
    })
    local cards = table.filter(player:getCardIds(Player.Hand), function (cid)
      return choice == U.ConvertSuit(Fk:getCardById(cid).suit, "int", "sym") 
    end)
    room:throwCard(cards, qiwo.name, player)
    room:addTableMark(target, "@wk_heg__qiwo-turn", choice)
  end,
})

qiwo:addEffect(fk.CardUsing, {
  is_delay_effect = true,
  mute = true,
  can_trigger = function (self, event, target, player, data)
    local suits = target:getTableMark("@wk_heg__qiwo-turn")
    return table.contains(suits, U.ConvertSuit(data.card.suit, "int", "sym"))
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    data.disresponsiveList = table.simpleClone(player.room.players)
  end
})

return qiwo
